<template>
  <div>
    <Meta pagealias="cityinfo_telindex" />
    <Head>同城电话本</Head>
    <div class="wrapper">
      <div class="search_wraper">
        <div class="search">
          <input type="text" v-model="keywords" @keyup.enter="search" placeholder="请输入名称或电话">
          <span class="search_btn" @click="search"></span>
        </div>
      </div>
      <ul class="tel_book_list">
        <li class="tel_book_item" v-for="(item, index) in phoneBookTypeList" :key="index" @click="$router.push('/cityinfo/book/' + item.id)">
          <img class="img-width-1" :src="item.logo_url ? item.logo_url : imgList[index]" alt="">
          <!-- <img class="img-width-1" :src="item.logo_url" alt=""> -->
          <p class="item_text">{{item.title}}</p>
        </li>
      </ul>
      <router-link class="register" :to="'/cityinfo/register'">我要登记</router-link>
    </div>
    <div class="height"></div>
    <BottomNav></BottomNav>
  </div>
</template>

<script>
import BottomNav from '../components/BottomNav.vue'
import http from '@/utils/http'
import api from '@/api'
export default{
  components: {
    BottomNav
  },
  data () {
    return {
      phoneBookTypeList: [],
      keywords: '',
      imgList: [
        require('../../../assets/images/cityinfo/tel-book-1.png'),
        require('../../../assets/images/cityinfo/tel-book-2.png'),
        require('../../../assets/images/cityinfo/tel-book-3.png'),
        require('../../../assets/images/cityinfo/tel-book-4.png'),
        require('../../../assets/images/cityinfo/tel-book-5.png'),
        require('../../../assets/images/cityinfo/tel-book-6.png'),
        require('../../../assets/images/cityinfo/tel-book-7.png'),
        require('../../../assets/images/cityinfo/tel-book-8.png'),
        require('../../../assets/images/cityinfo/tel-book-9.png'),
        require('../../../assets/images/cityinfo/tel-book-10.png'),
        require('../../../assets/images/cityinfo/tel-book-11.png'),
        require('../../../assets/images/cityinfo/tel-book-12.png'),
        require('../../../assets/images/cityinfo/tel-book-13.png'),
        require('../../../assets/images/cityinfo/tel-book-14.png'),
        require('../../../assets/images/cityinfo/tel-book-15.png'),
        require('../../../assets/images/cityinfo/tel-book-16.png'),
        require('../../../assets/images/cityinfo/tel-book-17.png'),
        require('../../../assets/images/cityinfo/tel-book-18.png'),
        require('../../../assets/images/cityinfo/tel-book-19.png'),
        require('../../../assets/images/cityinfo/tel-book-20.png'),
        require('../../../assets/images/cityinfo/tel-book-21.png'),
        require('../../../assets/images/cityinfo/tel-book-22.png'),
        require('../../../assets/images/cityinfo/tel-book-23.png'),
        require('../../../assets/images/cityinfo/tel-book-24.png'),
        require('../../../assets/images/cityinfo/tel-book-25.png'),
        require('../../../assets/images/cityinfo/tel-book-26.png'),
        require('../../../assets/images/cityinfo/tel-book-27.png'),
        require('../../../assets/images/cityinfo/tel-book-28.png')
      ]
    }
  },
  created () {
    this.getBookTypeList()
  },
  methods: {
    // 电话本分类列表数据获取
    getBookTypeList () {
      http.get(api.phone_book_type).then((res) => {
        this.phoneBookTypeList = res.data
      })
    },
    // 搜索
    search () {
      this.$router.push({
        path: '/cityinfo/book/0',
        query: {
          keywords: this.keywords
        }
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.height{
  height: 53px;
}
.wrapper{
  width: 355px;
  margin: 0 auto;
  padding-bottom: 15px;
  .register{
    width: 45px;
    height: 45px;
    line-height: 18px;
    text-align: center;
    border-radius: 50%;
    background: #1787fb;
    color:#ffffff ;
    font-size: 12px;
    padding: 5px;
    position: fixed;
    right: 7.5px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    box-shadow: 0px 0px 5px 3px #afd6fe;
  }
  .search_wraper{
    font-size: 15px;
    padding: 28px 0 25px;
    .search{
      width: 336px;
      height: 37px;
      padding-left: 15px;
      border: 1px solid #d0d0d0;
      border-radius: 30px;
      margin: 0 auto;
      font-size: 0;
      display: flex;
      input{
        width: 88%;
        height: 98%;
        border: none;
        font-size: 15px;
        &::placeholder{
          color:#b4bdc9;
        }
      }
      .search_btn{
        width: 30px;
        height: 100%;
        background: url(../../../assets/images/cityinfo/search.png) no-repeat center center / 13px 13px;
      }
    }
  }
  .tel_book_list{
    display: flex;
    flex-wrap: wrap;
    .tel_book_item{
      width:81.5px;
      height: 91px;
      border: 1px solid #d0d0d0;
      border-radius: 5px;
      margin: 0 9px 16px 0;
      line-height: 100%;
      text-align: center;
      box-shadow:0px 0px 2px 1px #e8e8e8;
      img{
        margin: 17px 0 0px;
      }
      &:nth-of-type(4n){
        margin-right: 0;
      }
      .item_text{
        color:#181818;
        font-size: 12px;
      }
      .img-width-1{
        width: 30px;
        height: 30px;
      }
    }
  }
}
</style>
